//
//  YGSexCell.m
//  yuanshangyiliao
//
//  Created by icholab on 2021/3/21.
//

#import "YGSexCell.h"
#import "YGDropdownListView.h"
#import "UIView+HHLayout.h"

@interface YGSexCell ()
@property (nonatomic, strong) YGDropdownListView *listView;
@property (nonatomic, assign) BOOL  isShowed;

@end
@implementation YGSexCell



- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self initView];
        [self initContraints];
    }
    return self;
}

- (void)initView{

    [self addContentView:self.listView];
//    [self addContentView:self.menuBtn];
//
    
}

-(void)initContraints{
//    [self.menuBtn mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerY.mas_equalTo(self.listView.centerY);
//        make.right.mas_equalTo(self.listView.right).offset(-10);
//    }];
}

- (void)setDefaultContent:(NSString *)content{
    [self.listView setDefaultContent:content];
    
}

-(void)configureData:(YGRegisterConfigureModel *)infoModel{
    if (self.tag == 109) {
        //患者属性
        self.listView.tableArray = infoModel.userTypes;
    }
}

#pragma setter
- (YGDropdownListView *)listView{
    if (!_listView) {
        _listView = [[YGDropdownListView alloc] initWithFrame:CGRectMake(0, 0, 100, 40)];
        WeakSelf(self);
        [_listView setCallBack:^(BOOL show) {
            weakself.isShowed = show;
            if (weakself.showCallBack) {
                weakself.showCallBack(show, weakself.tag);
            }
        }];
    }
    return _listView;
}

//- (UIButton *)menuBtn{
//    if (!_menuBtn) {
//        _menuBtn = [[UIButton alloc] init];
//        [_menuBtn setBackgroundImage:[UIImage imageNamed:@"dropdown_menu_icon"] forState:UIControlStateNormal];
//    }
//    return _menuBtn;
//}



- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event{

    UIView *view = [super hitTest:point withEvent:event];

    if (view == nil) {
        for (UIView *subView in self.listView.subviews) {
            CGPoint convertPoint = [subView convertPoint:point fromView:self];
            if (CGRectContainsPoint(subView.bounds, convertPoint)) {
                if ([subView isKindOfClass:[UITableView class]] && self.isShowed) {
                    view = subView;
                }
            }
        }
    }

    return view;
}

@end
